//
//  SettingOnlyInputCell.swift
//  XingCeHelper
//
//  Created by 申铭 on 2022/11/9.
//

import UIKit

let kSettingOnlyInputCell: String = "SettingOnlyInputCell"

class SettingOnlyInputCell: RoundCornerCell {
    
    @IBOutlet weak var nameTextField: UITextField!
    
    var model: SettingOnlyInputCellModel? {
        didSet {
            if let title = model?.title, !title.isEmpty {
                nameTextField.text = title
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        nameTextField.borderStyle = .none
        nameTextField.backgroundColor = .clear
        nameTextField.addTarget(self, action: #selector(textFieldEditChanged(textField:)), for: UIControl.Event.editingChanged)
    }
    
    @objc func textFieldEditChanged(textField: UITextField) {
        if let block = model?.inputResult {
            block(textField.text)
        }
    }
}
